<?php
$resultSet = getLastFlies();

?>
<!DOCTYPE  html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
  <meta http-equiv="Content-Type"
        content="text/html; charset=<?= getMessageByKey("default.charset") ?>"/>
  <title><?= getMessageByKey("indexflies.title") ?></title>
  <link rel="stylesheet" href="css/navigation.css">
  <link rel="stylesheet" type="text/css" href="css/menu.css">
  <link rel="stylesheet" type="text/css" href="css/index.css">
  <link rel="stylesheet" type="text/css" href="css/common.css">
  <script src="resources/jquery.js"></script>

  <meta name="keywords"
        content="<?= getMessageByKey("indexflies.keywords") ?>">
  <meta name="description" content="<?= getMessageByKey("indexflies.description") ?>">
</head>
<body class="body">

<?php
include_once("menu.php");
?>

<div class="maincommon">
  <?php
  $prefix = \controller\Config::getPropertyByKey('directory.preview.fly.main');

  $i = 0;
  while ($i < 3 && ($row = mysql_fetch_assoc($resultSet))) {

    ?>
    <div class="maindiv"
         style="background-image: url('<?= $prefix . $row['path'] ?>'); box-shadow: 0 0 5px rgba(0,0,0,1) ">
    </div>
    <div class="maindiv" onclick="location.href='?action=showfly&fid=<?= $row['id'] ?>'">
      <div class="commentdivheader">
        <?= processText($row['header']) ?>
      </div>
      <div class="commentdivcontent">
        <?= str_replace("\n", "<br>", $row['legend']) ?>
      </div>
      <div class="commentdivfooter">
        <?= getMessageByKey('general.number') ?> <?= $row['id'] ?><br>
        <?= getMessageByKey('general.date') ?> <?= $row['date'] ?><br>
        <?= getMessageByKey('general.time') ?> <?= $row['time'] ?><br>
        <?= getMessageByKey('indexflies.messages') ?> <?= countFlyComments($row['id']) ?>
      </div>
    </div>
    <?php
    $i++;
  }
  while (($row = mysql_fetch_assoc($resultSet)) && $i < 6) {

    ?>
    <div class="maindiv" onclick="location.href='?action=showfly&fid=<?= $row['id'] ?>'">
      <div class="commentdivheader">
        <?= processText($row['header']) ?>
      </div>
      <div class="commentdivcontent">
        <?= str_replace("\n", "<br>", $row['legend']) ?>
      </div>
      <div class="commentdivfooter">
        <?= getMessageByKey('general.number') ?> <?= $row['id'] ?><br>
        <?= getMessageByKey('general.date') ?> <?= $row['date'] ?><br>
        <?= getMessageByKey('general.time') ?> <?= $row['time'] ?><br>
        <?= getMessageByKey('indexflies.messages') ?> <?= countFlyComments($row['id']) ?>
      </div>
    </div>
    <div class="maindiv"
         style="background-image: url('<?= $prefix . $row['path'] ?>'); box-shadow: 0 0 5px rgba(0,0,0,1) ">

    </div>
    <?php
    $i++;
  }
  ?>
</div>

<?php
include_once("navigation.php");
?>

</body>
</html>
